package JDBC;

import org.junit.Test;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;

public class Add {
    public static void main(String[] args) throws SQLException {
        Connection conn = BaseDB.getConn();
        Statement st = conn.createStatement();

        String sql1 = "select max(id) from jdbc_info";
        ResultSet rs = st.executeQuery(sql1);
        int id = 1;
        if (rs.next()) {
            id = rs.getInt(1) + 1;
        }
        String sql = "insert into jdbc_info values(" + id + ",'李四',24)";
        int i = st.executeUpdate(sql);
        System.out.println(i);
        BaseDB.closeAll(conn, st, rs);
    }

    @Test
    public void add() throws SQLException {
        String sql="insert into jdbc_info values(4,'Mike',24)";
        BaseDB.updateSql(sql);
    }

}
